//
//  KHUICVCell_HomeScroll.m
//  EduCourse
//
//  Created by yanyan on 2017/8/9.
//  Copyright © 2017年 yanyan. All rights reserved.
//

#import "ECUICVCell_HomeScroll.h"
#import <SDCycleScrollView/SDCycleScrollView.h>
@interface ECUICVCell_HomeScroll()<SDCycleScrollViewDelegate>
@property(nonatomic,strong)SDCycleScrollView *adScrollView;
@end
@implementation ECUICVCell_HomeScroll
- (void)addSubviews
{
    [super addSubviews];
    self.adScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.contentView.bounds), 200) delegate:nil placeholderImage:nil];
    self.adScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    self.adScrollView.placeholderImage = [UIImage imageNamed:@"placeholder"];
    self.adScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleAnimated;
    self.adScrollView.delegate = self;
    self.adScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
    self.adScrollView.pageControlDotSize = CGSizeMake(11, 2);
    self.adScrollView.pageDotImage = [UIImage imageNamed:@"pageviewDot"];
    self.adScrollView.currentPageDotImage = [UIImage imageNamed:@"pageviewDot_current"];
//    self.adScrollView.currentPageDotColor = [UIColor whiteColor];
//    self.adScrollView.pageDotColor = [UIColor redColor];
    [self.contentView addSubview:self.adScrollView];
}
- (void)setObject:(id)object
{
    [super setObject:object];
    NSMutableArray *images = [NSMutableArray array];
    for(id obj in self.object){
        [images addObject:[NSString stringWithFormat:@"%@",[obj valueForKey:@"img"]]];

    }
    self.adScrollView.imageURLStringsGroup = images;
}
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    if (self.block_itemSelected) {
        self.block_itemSelected([self.object objectAtIndex:index]);
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
